package com.fr.chart.plot;

import com.fr.base.xml.XMLPrintWriter;
import com.fr.base.xml.XMLableReader;
import com.fr.chart.axis.CategoryAxis;
import com.fr.chart.axis.ValueAxis;
import com.fr.chart.core.glyph.BarPlotGlyph;
import com.fr.data.ChartData;

public abstract class BarPlot extends CategoryPlot
{
  private static final long serialVersionUID = 6388999613764540798L;
  protected boolean isHorizontal = false;
  protected double seriesOverlapPercent = -0.15D;
  protected double categoryIntervalPercent = 1.0D;

  public void install4PlotGlyph(BarPlotGlyph paramBarPlotGlyph, ChartData paramChartData)
  {
    super.install4PlotGlyph(paramBarPlotGlyph, paramChartData);
    paramBarPlotGlyph.setIsHorizontal(this.isHorizontal);
    paramBarPlotGlyph.setSeriesOverlapPercent(this.seriesOverlapPercent);
    paramBarPlotGlyph.setCategoryIntervalPercent(this.categoryIntervalPercent);
  }

  public void setIsHorizontal(boolean paramBoolean)
  {
    this.isHorizontal = paramBoolean;
    if (paramBoolean)
    {
      this.categoryAxis.setPosition(2);
      this.valueAxis.setPosition(3);
    }
    else
    {
      this.categoryAxis.setPosition(3);
      this.valueAxis.setPosition(2);
    }
  }

  public boolean isHorizontal()
  {
    return this.isHorizontal;
  }

  public void setSeriesOverlapPercent(double paramDouble)
  {
    this.seriesOverlapPercent = paramDouble;
  }

  public double getSeriesOverlapPercent()
  {
    return this.seriesOverlapPercent;
  }

  public void setCategoryIntervalPercent(double paramDouble)
  {
    this.categoryIntervalPercent = paramDouble;
  }

  public double getCategoryIntervalPercent()
  {
    return this.categoryIntervalPercent;
  }

  public boolean match4GUI(Plot paramPlot)
  {
    return ((super.match4GUI(paramPlot)) && (this.isHorizontal == ((BarPlot)paramPlot).isHorizontal));
  }

  public void readXML(XMLableReader paramXMLableReader)
  {
    super.readXML(paramXMLableReader);
    if (paramXMLableReader.isChildNode())
    {
      String str1 = paramXMLableReader.getTagName();
      if ("BarAttr".equals(str1))
      {
        String str2;
        if ((str2 = paramXMLableReader.getAttr("isHorizontal")) != null)
          setIsHorizontal(Boolean.valueOf(str2).booleanValue());
        if ((str2 = paramXMLableReader.getAttr("overlap")) != null)
          setSeriesOverlapPercent(Double.parseDouble(str2));
        if ((str2 = paramXMLableReader.getAttr("interval")) != null)
          setCategoryIntervalPercent(Double.parseDouble(str2));
      }
    }
  }

  public void writeXML(XMLPrintWriter paramXMLPrintWriter)
  {
    super.writeXML(paramXMLPrintWriter);
    paramXMLPrintWriter.startTAG("BarAttr").attr("isHorizontal", this.isHorizontal).attr("overlap", this.seriesOverlapPercent).attr("interval", this.categoryIntervalPercent).end();
  }

  public boolean equals(Object paramObject)
  {
    if (!(paramObject instanceof BarPlot))
      return false;
    BarPlot localBarPlot = (BarPlot)paramObject;
    if (!(super.equals(localBarPlot)))
      return false;
    if (localBarPlot.getCategoryIntervalPercent() != getCategoryIntervalPercent())
      return false;
    if (localBarPlot.getSeriesOverlapPercent() != getSeriesOverlapPercent())
      return false;
    return (localBarPlot.isHorizontal() == isHorizontal());
  }
}